package com.yizisu.mvvmlib.demo.base2Demo

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import com.yizisu.basemvvm.utils.isThis
import com.yizisu.mvvmlib.R
import com.yizisu.mvvmlib.baselib.base.BaseActivity
import com.yizisu.mvvmlib.demo.welcome.WelcomeActivity
import kotlinx.android.synthetic.main.activity_demo2.*

class Demo2Activity : BaseActivity() {
    override fun getContentResOrView(inflater: LayoutInflater): Any? = R.layout.activity_demo2

    override fun initUi(savedInstanceState: Bundle?) {
        super.initUi(savedInstanceState)
        loading.setOnClickListener {
            fragment.isThis<Demo2Fragment> {
                showLoadingView()
            }
        }
        content.setOnClickListener {
            fragment.isThis<Demo2Fragment> {
                showContentView()
            }
        }
        other.setOnClickListener {
            fragment.isThis<Demo2Fragment> {
                showOtherView()
            }
        }
        WelcomeActivity.testLiveData.registerOnSuccess {
            println("我是第二个界面，收到回调")
        }
    }


    override fun isNeedToolbar(): Boolean {
        return true
    }

    override fun isNeedSwitchView(): Boolean {
        return false
    }

    override fun onResume() {
        super.onResume()
        val view = window.decorView.findViewById<View>(android.R.id.content)
        println()
    }
}
